<template>
	<view>
		<uni-nav-bar left-icon="back" left-text="返回" :border="false" title="设置"
		 status-bar fixed @clickLeft="backLastPage"
		></uni-nav-bar>
		<view class="flex align-center border-bottom p-4">
			<text class="font-md">头像</text>
			<view class="flex-1 flex justify-end align-center">
				<image src="/static/icon/business-management.png" class="m-r-2 rounded-circle" style="width: 80rpx; height: 80rpx;"></image>
			</view>
		</view>
		<view class="flex align-center border-bottom p-4">
			<text class="font-md">名字</text>
			<view class="flex-1 flex justify-end align-center">
				<text>{{name}}</text>
			</view>
		</view>
		
		<view class="p-3 mt-4">
			<button class="bg-main text-white" style=" background-color: #02C9FC; border-radius: 50rpx;" type="primary"
			 @tap="loginOut">退出登录</button>
		</view>
		
		<view style="margin-top: 15rpx;" class="p-3 mt-4">
			<button style="background-color: #02C9FC; border-radius: 50rpx;" class="bg-main text-white" type="primary"
			  @tap="toChange" >修改密码</button>
		</view>
	</view>
</template>

<script>
	import uniNavBar from '@/components/uni/uni-nav-bar/uni-nav-bar.vue';
	import {Decrypt,Encrypt} from '../../../static/util/crypto.js'
	export default {
		components: {
			uniNavBar
		},
		data() {
			return {
				name:''
			}
		},
		async onLoad() {
			//获取用户名
			var that = this;
			that.name = uni.getStorageSync('nickName') || '未知';
			// var res = await that.$api.getName();
			
			// console.log(Decrypt(res.data.result));
		},
		methods: {
			loginOut () {
				uni.showModal({
				    title: '提示',
				    content: '注销登录吗？',
				    success: (res) => {
				        if (res.confirm) {
							uni.request({
								url:'http://192.168.78.107:8079/api/app/logout',
								method:'POST',
								success: (res) => {
									uni.clearStorage();

									uni.removeStorageSync('nickName');
									uni.removeStorageSync('token');
									uni.removeStorageSync('phone');
									uni.reLaunch({
									    url: '../../index/index'
									});
								}
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			toChange(){
				uni.navigateTo({
					url:'../../login/changePass'
				})
			},
			backLastPage () {
				uni.navigateBack({
				    delta: 1
				});
			}
		}
	}
</script>

<style>

</style>
